package exp.day02;

import java.util.Arrays;

//把一个文章中所有单词排序输出，相同的单词只保留一个
public class P04_Teacher {
    public static void main(String[] args) {
        String s = "You think you can, you do you like, you wish you think.";
        String[] words = s.toLowerCase().split("\\W+"); //表示匹配数字、字母、下划线和加号本身字符
        System.out.println(Arrays.toString(words));
        Arrays.sort(words); //排序基本对象类型，但是不可以使用基本数据类型,默认的是升序排序
        String recent = words[0];
        System.out.println(words[0]);
        for (int i = 1; i < words.length; i++) {
            if (words[i].equals(recent)) continue;
            System.out.println(words[i]);
            recent = words[i];
        }
    }
}
